
use std::fs::{ File, OpenOptions};

/// create if not exists or open file if exists on the specified file path e.g. ./sqlite/ebmaster.db
pub fn cropen_file_path(file_path: &str) -> File {
    let file_path = file_path.replace("\\", "/");
    if let Some(right) = file_path.rfind("/") {
      let path = &file_path[0..right];
      std::fs::create_dir_all(path).expect(&format!("Failed to create path={}", path));
    }
  
    println!("cropen_file_path file_path={}",file_path);
    
    OpenOptions::new()
      .create(true)
      .write(true)
      .open(&file_path)
      .expect(&format!("Failed to create path={}", file_path))
  }
  